import axios from 'axios'
import { showNotify } from 'vant'

// axios.defaults.baseURL = 'http://localhost:3000'
axios.interceptors.request.use((config) => {
  const { url, method, data } = config
  console.log({ url, method, data })
  return config
})
axios.interceptors.response.use(
  (response) => {
    if (response.data.status === 20001) {
      // 全局异常处理
      showNotify({ message: '请求异常' })
    }
    console.log(response.data)
    return response.data
  },
  (err) => {
    return Promise.reject(err)
  }
)

export default axios
